var paperId="";
var arrayObj = new Array();
var arrayTitleNo= new Array();
$(function() {
	var thisURL =document.URL;  
	var getval =thisURL.split('?')[1];
	paperId =getval.split("=")[1];

	$.ajax({
		url : "../PaperController/findByCondition.action",
		dataType : 'json',  
		async : false,  
		data:{"paperId":paperId}, 
		success : function(data) {
			$.each(data, function(i, n) {	
				$("#paperName").html(n.paperName);
			});
		}
	});
	
	$.ajax({
		url : "../PaperTitleController/findByCondition.action",
		dataType :'json',  
		async : false,  
		data:{"paperId":paperId}, 
		success : function(data) {
		     var str='';
		     var paperNum=data.length;
		     var i=0;
		   
		     for(i=0;i<paperNum;i++){
		     str='<ul>'+
				      '<div style="background:pink;height：30px;font-size:20px;">'+
				      '<input type="hidden" id="paperNum" value="'+paperNum+'">'+ 
				      '<input type="hidden" id="titleId" name="titleId" value="'+paperId+'">'+
				      '<span>'+data[i].extend2+'、</span>'+'<strong>'+data[i].titleName+'</strong>' +
				      '</div>'+
	                   "<li>"+
				       '<div style="font-size:16px;margin-top:15px;" id="'+data[i].extend2+'_div1'+'">'+
				       '<input type="radio" id="'+data[i].extend2+'_1'+'" name="'+data[i].extend2+'" style="vertical-align:middle; margin-top:-2px; margin-bottom:1px;" value="A">'+
				     	'<label for='+data[i].extend2+'_1'+'>'+"A："+data[i].answera+'</label>'+
				       '</div>'+
	                 '</li>'+
	                 "<li>"+
				       '<div  style="font-size:16px;margin-top:5px;id="'+data[i].extend2+'_div2'+'">'+
				       '<input type="radio" id="'+data[i].extend2+'_2'+'" name="'+data[i].extend2+'"  style="vertical-align:middle; margin-top:-2px; margin-bottom:1px;" value="B">'+
				     	'<label for='+data[i].extend2+'_2'+'>'+"B："+data[i].answerb+'</label>'+
				       '</div>'+
	                 '</li>'+
				       "<li>"+
				       '<div  style="font-size:16px;margin-top:5px;id="'+data[i].extend2+'_div3'+'">'+
				       '<input type="radio" id="'+data[i].extend2+'_3'+'" name="'+data[i].extend2+'"  style="vertical-align:middle; margin-top:-2px; margin-bottom:1px;" value="C">'+
				     	'<label for='+data[i].extend2+'_3'+'>'+"C："+data[i].answerc+'</label>'+
				       '</div>'+
	                 '</li>'+
				       "<li>"+
				       '<div  style="font-size:16px;margin-top:5px;id="'+data[i].extend2+'_div4'+'">'+
				       '<input type="radio" id="'+data[i].extend2+'_4'+'" name="'+data[i].extend2+'"  style="vertical-align:middle; margin-top:-2px; margin-bottom:1px;" value="D">'+
				     	'<label  for='+data[i].extend2+'_4'+'>'+"D："+data[i].answerd+'</label>'+
				       '</div>'+
	                 '</li>'+'</br>'
				   +'</ul>';
				       $('#divPaper').append(str);
				       var name=data[i].extend2;
				       $('#titleNo').val(name);
				       arrayObj[i]=name;
				       arrayTitleNo.push(data[i].titleId);
			}}
	});
});

$("#submitUserPaper").click(function(){
	  var array = new Array();
      for(var i=0;i<arrayObj.length;i++){
	      var str=$('input:radio[name="'+arrayObj[i]+'"]:checked').val(); 
	      array.push(str);  
      }
      $("#userAnswer").val(array);
      $("#titleList").val(arrayTitleNo);
      alert($("#userAnswer").val());
      $("#userTitleForm").submit();
      
    });

returnAccess();
var curRow = {};
function returnAccess() {
	$("#paperTitle").bootstrapTable({
				toolbar : "#toolbar",
				idField : "id",
				pagination : true,
				showRefresh:true,
				pageSize : 10,
				search : true,
				showExport: true, 
			    exportTypes: ['txt','excel'],
				queryParams : function(param) {
					var thisURL = document.URL;  
					var  getval =thisURL.split('?')[1];
					paperId= getval.split("=")[1];
					return {
						paperId: paperId,
				    };
				},
				url : "../PaperTitleController/findByCondition.action",
				columns : [
						{
							field : "titleName",
							title : "题目"
							
						},
						{
							field : "answera",
							title : "选项A",
							
						},
						{
							field : "answerb",
							title : "选项B",
							
						},
						{
							field : "answerc",
							title : "选项C",
							
						},
						{
							field : "answerd",
							title : "选项D",
							
						}
					],
				
			});
};